import { axios } from '@/utils/request'

const api = {
  user: '/system/user',
  role: '/system/role',
  permission: '/system/menu',
  org: '/system/org',
  dictType: '/system/dict/type',
  dictData: '/system/dict/data',
  dist: '/system/districts',
  config: '/system/config',
  oss: '/system/oss',
  refInData: 'ref/in/record',
  refOutData: 'ref/out/record',
  refCharts: 'ref/statistics'
}

export default api

// 统计-转诊流向
// startDate-endDate
export function refFlow (parameter) {
  return axios({
    url: api.refCharts + '/getRefFlow',
    method: 'get',
    params: parameter
  })
}
// 统计-科室占比分析
export function getDiseaseRanking (parameter) {
  return axios({
    url: api.refCharts + '/getDiseaseRanking',
    method: 'get',
    params: parameter
  })
}
// 统计-转诊趋势
export function refChartTrend (parameter) {
  return axios({
    url: api.refCharts + '/getRefTrend',
    method: 'get',
    params: parameter
  })
}
// 统计-机构转入转出人次
// unitRanking
export function refChartIntoNumber (parameter) {
  return axios({
    url: api.refCharts + '/getRefIntoNumber',
    method: 'get',
    params: parameter
  })
}
// 统计-转入转出明细
export function refRollOutUnit (parameter) {
  return axios({
    url: api.refCharts + '/getRollOutUnit',
    method: 'get',
    params: parameter
  })
}
// 转出审核
export function refOutApproval (parameter) {
  console.log('请求参数', parameter)
  return axios({
    url: api.refOutData + '/approvalMain',
    method: 'post',
    params: parameter
  })
}
// 转出列表
export function refOutRecordList (parameter) {
  console.log(parameter)
  return axios({
    url: api.refOutData + '/getRefOutRecordlist',
    method: 'get',
    params: parameter
  })
}
// 转诊申请新增
export function refOutApplySave (parameter) {
  console.log('保存参数', parameter)
  return axios({
    url: api.refOutData + '/save',
    method: 'post',
    data: parameter
  })
}
// 申请转诊根据住院号自动填写数据
export function refOutApplyInfo (parameter) {
  console.log('住院号', parameter)
  return axios({
    url: api.refOutData + '/getBasicInformation',
    method: 'get',
    params: parameter
  })
}

// 查看电子病历
export function selElectronicRecords (outRecordId) {
  return axios({
    url: api.refInData + '/selElectronicRecords',
    method: 'get',
    params: outRecordId
  })
}
// 转诊转入修改
// refInRecord
export function refInUpdate (parameter) {
  return axios({
    url: api.refInData + '/update',
    method: 'post',
    data: parameter
  })
}

// 报到提交
export function refInSave (parameter) {
  return axios({
    url: api.refInData + '/save',
    method: 'post',
    data: parameter
  })
}

// 转入列表
export function refInData (parameter) {
  console.log(parameter)
  return axios({
    url: api.refInData + '/list',
    method: 'get',
    params: parameter
  })
}

// user
export function getUserList (parameter) {
  return axios({
    url: api.user + '/list',
    method: 'get',
    params: parameter
  })
}

export function getUser (userId) {
  return axios({
    url: api.user + '/get/' + `${userId}`,
    method: 'get'
  })
}
export function saveUser (parameter) {
  return axios({
    url: api.user + (parameter.userId ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delUser (parameter) {
  return axios({
    url: api.user + '/remove',
    method: 'post',
    params: parameter
  })
}
export function changUserStatus (parameter) {
  return axios({
    url: api.user + '/status',
    method: 'post',
    data: parameter
  })
}
export function resetPwd (parameter) {
  return axios({
    url: api.user + '/resetPwd',
    method: 'post',
    data: parameter
  })
}

// role
export function getRoleList (parameter) {
  return axios({
    url: api.role + '/list',
    method: 'get',
    params: parameter
  })
}
export function getRoleAll () {
  return axios({
    url: api.role + '/all',
    method: 'get'
  })
}

export function saveRole (parameter) {
  return axios({
    url: api.role + (parameter.roleId ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function delRole (parameter) {
  return axios({
    url: api.role + '/remove',
    method: 'post',
    params: parameter
  })
}
export function changRoleStatus (parameter) {
  return axios({
    url: api.role + '/status',
    method: 'post',
    data: parameter
  })
}
export function authDataScope (parameter) {
  return axios({
    url: api.role + '/authDataScope',
    method: 'post',
    data: parameter
  })
}

// menu
export function getPermissionAll (parameter) {
  return axios({
    url: api.permission + '/all',
    method: 'get',
    params: parameter
  })
}
export function getPermissions (parameter) {
  return axios({
    url: api.permission + '/list',
    method: 'get',
    params: parameter
  })
}
export function getRolePermIds (roleId) {
  return axios({
    url: api.permission + '/role/' + `${roleId}`,
    method: 'get'
  })
}

export function savePerm (parameter) {
  return axios({
    url: api.permission + (parameter.menuId ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function delPerm (orgId) {
  return axios({
    url: api.permission + '/remove/' + `${orgId}`,
    method: 'post'
  })
}

// org
export function getOrgList (parameter) {
  return axios({
    url: api.org + '/list',
    method: 'get',
    params: parameter
  })
}
export function getOrgListEnable (parameter) {
  return axios({
    url: api.org + '/list/enable',
    method: 'get',
    params: parameter
  })
}
export function getRoleOrgIds (roleId) {
  return axios({
    url: api.org + '/role/' + `${roleId}`,
    method: 'get'
  })
}
export function saveOrg (parameter) {
  return axios({
    url: api.org + (parameter.orgId ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function delOrg (orgId) {
  return axios({
    url: api.org + '/remove/' + `${orgId}`,
    method: 'post'
  })
}
// dictType
export function getDictTypeList (parameter) {
  return axios({
    url: api.dictType + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveDictType (parameter) {
  return axios({
    url: api.dictType + (parameter.dictId ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delDictType (parameter) {
  return axios({
    url: api.dictType + '/remove',
    method: 'post',
    params: parameter
  })
}

// dictData
export function getDictDataList (parameter) {
  return axios({
    url: api.dictData + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveDictData (parameter) {
  return axios({
    url: api.dictData + (parameter.dictCode ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delDictData (parameter) {
  return axios({
    url: api.dictData + '/remove',
    method: 'post',
    params: parameter
  })
}
// dist 地区
export function getDistList (parameter) {
  return axios({
    url: api.dist + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveDist (parameter) {
  return axios({
    url: api.dist + (parameter.id ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delDist (parameter) {
  return axios({
    url: api.dist + '/remove',
    method: 'post',
    params: parameter
  })
}
// config 配置
export function getConfigList (parameter) {
  return axios({
    url: api.config + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveConfig (parameter) {
  return axios({
    url: api.config + (parameter.configId ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delConfig (parameter) {
  return axios({
    url: api.config + '/remove',
    method: 'post',
    params: parameter
  })
}
// oss
export function getOssList (parameter) {
  return axios({
    url: api.oss + '/list',
    method: 'get',
    params: parameter
  })
}
export function saveOss (parameter) {
  return axios({
    url: api.oss + (parameter.id ? '/update' : '/save'),
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
export function delOss (parameter) {
  return axios({
    url: api.oss + '/remove',
    method: 'post',
    params: parameter
  })
}
export function getOssConfig () {
  return axios({
    url: api.oss + '/config',
    method: 'get'
  })
}
export function saveOssConfig (parameter) {
  return axios({
    url: api.oss + '/saveConfig',
    method: 'post',
    params: parameter
  })
}


//上传
export function uploadFile (file) {
  return axios({
    url: `/dfs/dfs/upload`,
    method: 'post',
    data: file,
    headers: {
      'Content-Type' : 'multipart/form-data'
    }
  })
}
//下载
export function downloadFile(url){
  return axios({
    url: url,
    method: 'get',
    responseType : 'blob',
    
  })
}